//
//  applyCell.m
//  FastDoctor
//
//  Created by 云卷云舒丶 on 16/7/6.
//  Copyright © 2016年 sc. All rights reserved.
//

#import "applyCell.h"


@interface applyCell()
@property(nonatomic,weak)UILabel * sickPersonName;
@property(nonatomic,weak)UILabel * diseaseName;
@property(nonatomic,weak)UILabel * seeDoctorTime;
@property(nonatomic,weak)UILabel * doctorName;
@property(nonatomic,weak)UILabel * doctorPosition;
@property(nonatomic,weak)UILabel * hospitalName;
@property(nonatomic,weak)UIButton * stateButton;
@property(nonatomic,weak)UIView * threadView;
@property(nonatomic,weak)UIImageView * arrowImage;


@end
@implementation applyCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ( self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 界面的初始化
          [self setupUI];
    }
 
    return  self ;

}

- (void)setupUI{
    

    //    病人状态
    UIButton * stateButton = [[UIButton alloc]init];
    self.stateButton = stateButton;
    [self.contentView addSubview:_stateButton];
    stateButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [stateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    stateButton.backgroundColor = [UIColor colorWithRed:57/225.0 green:197/225.0 blue:196/225.0 alpha:1];
    [_stateButton mas_makeConstraints:^(MASConstraintMaker *make) {
//       水平
        make.centerY.equalTo(self.contentView.mas_centerY);
//        右边间距
        make.right.equalTo(self.contentView).offset(-20);
        
//        上下间距
//        make.top.equalTo(self.contentView).offset(15);
//        make.bottom.equalTo(self.contentView).offset(-15);

        make.height.and.width.equalTo(@60);
        
    }];
    stateButton.layer.cornerRadius= 30;
    
    //    箭头VIew
    
    UIImageView * arrowImage = [[UIImageView alloc]init];
    self.arrowImage = arrowImage;
    
    arrowImage.image = [UIImage imageNamed:@"illness_button_input_blue.png"];
    
    [self.contentView addSubview:_arrowImage];
    
    [_arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        //        水平
        make.centerY.equalTo(self.contentView.mas_centerY);
        
        make.left.equalTo(_stateButton.mas_right).offset(2);
        
        
    }];
    
    
    
    
    UIView * threadView = [[UIView alloc]init];
    self.threadView = threadView;
    self.threadView.backgroundColor = [UIColor colorWithRed:57/225.0 green:197/225.0 blue:196/225.0 alpha:1];
    [self.contentView addSubview:threadView];
    
    [threadView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.contentView.mas_centerY);
        //        线宽
        make.height.mas_equalTo(1);
        //        左边间距为10，同时设置宽度
        make.leading.mas_equalTo(10);
        //        右边间距为10同时设置宽度
        make.trailing.mas_equalTo(-80);
  
//        设置整条宽度
//        make.width.mas_equalTo(self.contentView);

    }];

//    病人名
    UILabel *sickPersonName =[[UILabel alloc]init];
    self.sickPersonName =sickPersonName;
    
    [_sickPersonName setFont:[UIFont systemFontOfSize:16]];
    
    [self.contentView addSubview:_sickPersonName];
    
    [_sickPersonName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(self.contentView).offset(10);
    }];
    
//    病名
    UILabel * diseaseName = [[UILabel alloc]init];
    self.diseaseName = diseaseName;
    
    [_diseaseName setFont:[UIFont systemFontOfSize:16]];
    [self.contentView addSubview:_diseaseName];
    [_diseaseName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(_sickPersonName.mas_right).offset(10);
    }];
    

    
//    就诊时间
    UILabel * seeDoctorTime = [[UILabel alloc]init];
    self.seeDoctorTime = seeDoctorTime;
    
    [_seeDoctorTime setFont:[UIFont systemFontOfSize:16]];
    [self.contentView addSubview:_seeDoctorTime];
    [_seeDoctorTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.right.equalTo(_stateButton.mas_left).offset(-15);

    }];

    
//    医生名
    UILabel * doctorName = [[UILabel alloc]init];
    self.doctorName = doctorName;
    
    [_doctorName setFont:[UIFont systemFontOfSize:16]];
    [self.contentView addSubview:_doctorName];
    [_doctorName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(-15);
        
    }];

//    医生职位
    UILabel * doctorPosition = [[UILabel alloc]init];
    self.doctorPosition = doctorPosition;
    
    [_doctorPosition setFont:[UIFont systemFontOfSize:16]];
    [self.contentView addSubview:_doctorPosition];
    [_doctorPosition mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_doctorName.mas_right).offset(10);
        make.bottom.equalTo(self.contentView).offset(-15);
    }];

//    医院名
    UILabel * hospitalName= [[UILabel alloc]init];
    self.hospitalName = hospitalName;
    
    [_hospitalName setFont:[UIFont systemFontOfSize:16]];
    [self.contentView addSubview:_hospitalName];
    [_hospitalName mas_makeConstraints:^(MASConstraintMaker *make) {
    make.right.equalTo(_stateButton.mas_left).offset(-15);
    make.bottom.equalTo(self.contentView).offset(-15);
    }];
    if (kDevice_Is_iPhone5) {
        self.sickPersonName.font = [UIFont systemFontOfSize:12];
        self.diseaseName.font = [UIFont systemFontOfSize:12];
        self.seeDoctorTime.font = [UIFont systemFontOfSize:12];
        self.doctorName.font = [UIFont systemFontOfSize:12];
        self.doctorPosition.font = [UIFont systemFontOfSize:12];
        self.hospitalName.font = [UIFont systemFontOfSize:12];
    }
}


-(void)setModel:(applyModel *)model{
    _model = model;
    
//    病人名
    _sickPersonName.text = model.sickPersonName;
//    病名
    _diseaseName.text = model.diseaseName;
//    就诊时间
    _seeDoctorTime.text = model.seeDoctorTime;
//    医生名
    _doctorName.text = model.doctorName;
//    医生职位
    _doctorPosition.text = model.doctorPosition;
//    医院名
    _hospitalName.text = model.hospitalName;
    
    [_stateButton setTitle:@"审核中" forState:UIControlStateNormal];
    
    _stateButton.selected = NO;

    [_stateButton addTarget:self action:@selector(didClickStateButton) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)didClickStateButton{
    
   
    
    if (_stateButton.selected)
    {
        [_stateButton setTitle:@"审核中" forState:UIControlStateNormal];
        _stateButton.selected = NO;
        _model.is_check = NO;
    }
    else{
    
        [_stateButton setTitle:@"已就诊" forState:UIControlStateSelected];
        _stateButton.selected = YES;
        _model.is_check = YES;

    }
    
}


@end
























